package com.hua.controller;

import com.hua.common.Response;
import com.hua.domain.Category;
import com.hua.domain.domainVo.CategoryVo;
import com.hua.domain.domainVo.CommodityPriceVo;
import com.hua.service.CategoryService;
import com.hua.service.impl.CommodityInfoServiceImpl;
import com.hua.util.FaceClass;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.List;

/**
 * @program: git
 * @description:
 * @author: feng
 * @create: 2022-10-19 11:00
 **/
@Api("操作商品种类")
@RestController
@RequestMapping("/category")
public class CategoryController {
    @Resource
    private CategoryService categoryServiceImpl;

    @Resource
    private CommodityInfoServiceImpl commodityInfoService;

    @Resource
    private FaceClass faceClass;
    /**
    * @Description:  获取商品类型
    * @Param:
    * @return:  Response<List<Category>>
    * @Author: 黄燕峰
    */

    @ApiOperation("获取商品类型")
    @PostMapping("/getCategory")
    public Response<List<Category>> getAll(){
        return categoryServiceImpl.getCategory();
    }

    @ApiOperation("增加商品种类列表")
    @PostMapping("/addCategory")
    public Response<String> addCategory(@RequestBody CategoryVo categoryVo){
        return categoryServiceImpl.addCategory(categoryVo);
    }

    @ApiOperation("删除商品种类")
    @DeleteMapping("/deleteCategory/{categoryId}")
    public Response<String> deleteCategoryById(@PathVariable("categoryId") Integer categoryId){
        return categoryServiceImpl.deleteCategoryById(categoryId);
    }




    @PostMapping( "/uploadImg")
    @ApiOperation("上传图片")
    public Response uploadImg(@RequestPart(value = "file")MultipartFile file){
        return faceClass.uploadFace(file);
    }
    @PostMapping("/user/userInfo")
    @ApiOperation("更新头像接口")
    public Response<String> updateUserFace(@RequestBody CategoryVo categoryVo) {
        return faceClass.saveFace(categoryVo);
    }


    @PostMapping("/getCategoryKind")
    @ApiOperation("获得特定的商品种类")
    public Response<List<CommodityPriceVo>> getCategory(String kind){
        return categoryServiceImpl.getKind(kind);
    }

}
